import router from '../router'
import axios from './axios'

axios.interceptors.request.use(function(res) {
  let user_token =""
  if(window.localStorage.hasOwnProperty('user_token')){
    user_token = window.localStorage.getItem('user_token')
  }
  res.headers.common['Merchant-token'] = user_token
  return res
})

axios.interceptors.response.use(function(response) {
  // 重定向到登录页面
  if (response && response.data && response.data.hasOwnProperty("data") && response.data.data == 'no_login') {
     router.replace({ path: '/login' })
     return response
  } else {
    return response
  }
  return response
})

export const baseUrl = 'https://qzl.dindong.cn/api/'
export const UPLOAD_IMG = 'https://qzl.dindong.cn/api/file/upload-img/'
export const UPLOAD_EXCEL = 'https://qzl.dindong.cn/api/excel/uploadExcel/'
export const ueditorUrl = 'https://qzl.dindong.cn/ueditor-php/controller.php'

//注册
export const  signUp = (params) => axios.post('merchant/auth/signUp',params)
//校验账号唯一性
export const  usernameVerify = (params) => axios.get('merchant/auth/usernameVerify',{"params":{...params}})
//登陆
export const  signIn = (params) => axios.post('merchant/auth/signIn',params)
//退出登录
export const  loginOut = () => axios.get('merchant/auth/loginOut')
//获取商户管理员信息
export const  getMerchantUserInfo = () => axios.get('merchant/auth/getMerchantUserInfo')
//获取验证码
export const  sendVerificationCode = (params) => axios.post('auth/sendVerificationCode',params)
//商家审核
export const  enterpriseReview = (params) => axios.post('merchant/auth/enterpriseReview',params)
//获取商家审核状态
export const  getEnterpriseReviewStatus = () => axios.get('merchant/auth/getEnterpriseReviewStatus')

//获取授权页面地址
// const  getPreAuthorizationPage = 'https://yaogeeks.dindong.cn/api/wechatthird/getPreAuthorizationPage'
//设置小程序支付方式 废除
//export const  setWxappPayment = (params) => axios.post('merchant/auth/setWxappPayment',params)
//获取小程序支付方式 废除
//export const  getWxappPayment = () => axios.get('merchant/auth/getWxappPayment')


//完善微信支付信息
export const  setWechatPayConfig = (params) => axios.post('wechatthird/setWechatPayConfig',params)
//获取设置的微信支付配置
export const  getWechatPayConfig = () => axios.get('wechatthird/getWechatPayConfig')

//查询授权状态
export const  checkAuthorizeStatus = () => axios.get('merchant/checkAuthorizeStatus')
//查询授权信息
export const  checkAuthorizeInfo = () => axios.get('merchant/checkAuthorizeInfo')
//上传微信支付证书
export const  uploadCart = (params) => axios.post('wechatthird/uploadCart',params)


//商家数据统计
export const  getEnterpriseDataSummary = () => axios.get('merchant/data/getEnterpriseDataSummary')
//门店营收数据
export const  getMerchantSelling = (params) => axios.get('merchant/data/getMerchantSelling',{"params":{...params}})
//全天订单量统计
export const  getOrderCounts = (params) => axios.get('merchant/data/getOrderCounts',{"params":{...params}})
//复购率
export const  getReBuyRate = (params) => axios.get('merchant/data/getReBuyRate',{"params":{...params}})
//获取商品类型销售情况
export const  getClassifySelling = (params) => axios.get('merchant/data/getClassifySelling',{"params":{...params}})


//获取角色列表
export const  roleList = (params) => axios.get('merchant/auth/roleList',{"params":{...params}})
//添加角色
export const  setRole = (params) => axios.post('merchant/auth/setRole',params)
//删除角色
export const  delRole = (params) => axios.post('merchant/auth/delRole',params)
//获取权限列表
export const  permissionsList = (params) => axios.get('merchant/auth/permissionsList',{"params":{...params}})
//角色信息
export const  roleSet = (params) => axios.get('merchant/auth/roleSet',{"params":{...params}})


//获取管理员列表
export const adminList = (params) => axios.get('merchant/auth/adminList',{"params":{...params}})
//添加管理员用户
export const setAdmin = (params) => axios.post('merchant/auth/setAdmin',params)
//删除管理员用户
export const delAdmin = (params) => axios.post('merchant/auth/delAdmin',params)
//改变管理员状态
export const changeAdminStatus = (params) => axios.post('merchant/auth/changeAdminStatus',params)
//管理员信息
export const  adminSet = (params) => axios.get('merchant/auth/adminSet',{"params":{...params}})
//修改密码
export const changePassword = (params) => axios.post('merchant/auth/changePassword',params)

//门店列表
export const getMerchantList = (params) => axios.get('merchant/getMerchantList',{"params":{...params}})
//编辑门店
export const setMerchant = (params) => axios.post('merchant/setMerchant',params)
//删除门店
export const  delMerchant = (params) => axios.post('merchant/delMerchant',params)
//门店详情
export const  getMerchantDetail = (params) => axios.get('merchant/getMerchantDetail',{"params":{...params}})

//设置配送方式
export const  setMerchantDeliveryMethod = (params) => axios.post('merchant/setMerchantDeliveryMethod',params)
//改变营业状态
export const  changeMerchantStatus = (params) => axios.post('merchant/changeMerchantStatus',params)

//编辑商品分类
export const  setGoodsClassify = (params) => axios.post('merchant/setGoodsClassify',params)
//商品分类列表
export const  getGoodsClassifyList = (params) => axios.get('merchant/getGoodsClassifyList',{"params":{...params}})
//删除商品分类
export const  delGoodsClassify = (params) => axios.post('merchant/delGoodsClassify',params)
//商品分类详情
export const getGoodsClassifyDetail = (params) => axios.get('merchant/getGoodsClassifyDetail',{"params":{...params}})

//门店员工列表
export const  getMerchantStaffList = (params) => axios.get('merchant/getMerchantStaffList',{"params":{...params}})
//门店员工详情
export const getMerchantStaffDetail = (params) => axios.get('merchant/getMerchantStaffDetail',{"params":{...params}})
//编辑门店员工
export const  setMerchantStaff = (params) => axios.post('merchant/setMerchantStaff',params)
//删除门店员工
export const  delMerchantStaff = (params) => axios.post('merchant/delMerchantStaff',params)


//编辑商品
export const  setGoods = (params) => axios.post('merchant/goods/setGoods',params)
//商品列表
export const  getGoodsList = (params) => axios.get('merchant/goods/getGoodsList',{"params":{...params}})
//商品详情
export const  getGoodsDetail = (params) => axios.get('merchant/goods/getGoodsDetail',{"params":{...params}})
//设置商品规格
export const  setGoodsSpu = (params) => axios.post('merchant/goods/setGoodsSpu',params)
//商品规格列表
export const  getGoodsSpuList = (params) => axios.get('merchant/goods/getGoodsSpuList',{"params":{...params}})
//商品规格详情
export const  getGoodsSpuDetail = (params) => axios.get('merchant/goods/getGoodsSpuDetail',{"params":{...params}})
//删除商品规格
export const  delGoodsSpu = (params) => axios.post('merchant/goods/delGoodsSpu',params)
//商品审核列表
export const  getGoodsApplyList = (params) => axios.get('merchant/goods/getGoodsApplyList',{"params":{...params}})
//审核的商品详情
export const  getGoodsApplyDetail = (params) => axios.get('merchant/goods/getGoodsApplyDetail',{"params":{...params}})
//改变上下架状态
export const  changeGoodsShop = (params) => axios.post('merchant/goods/changeGoodsShop',params)
//删除商品
export const  delGoods = (params) => axios.post('merchant/goods/delGoods',params)

//通过upc码获取商品库信息
export const  getSystemMedicineByUpc = (params) => axios.get('merchant/goods/getSystemMedicineByUpc',{"params":{...params}})

//获取所有的upc码
export const  getSystemMedicineUpcList = (params) => axios.get('merchant/goods/getSystemMedicineUpcList',{"params":{...params}})

//专区列表
export const  getMerchantMedicineAreaList = (params) => axios.get('merchant/wxapp/getMerchantMedicineAreaList',{"params":{...params}})
//删除专区
export const  delMerchantMedicineArea = (params) => axios.post('merchant/wxapp/delMerchantMedicineArea',params)
//专区详情
export const  getMerchantMedicineAreaDetail = (params) => axios.get('merchant/wxapp/getMerchantMedicineAreaDetail',{"params":{...params}})
//设置专区
export const  setMerchantMedicineArea = (params) => axios.post('merchant/wxapp/setMerchantMedicineArea',params)

//专区绑定的商品列表
export const  getMerchantMedicineXAreaList = (params) => axios.get('merchant/wxapp/getMerchantMedicineXAreaList',{"params":{...params}})
//专区绑定商品
export const  setMerchantMedicineXArea = (params) => axios.post('merchant/wxapp/setMerchantMedicineXArea',params)
//删除专区绑定的商品
export const  delMerchantMedicineXArea = (params) => axios.post('merchant/wxapp/delMerchantMedicineXArea',params)


//设置轮播图
export const  setBanner = (params) => axios.post('merchant/wxapp/setBanner',params)
//删除轮播图
export const  delBanner = (params) => axios.post('merchant/wxapp/delBanner',params)
//banner详情
export const  getBannerDetail = (params) => axios.get('merchant/wxapp/getBannerDetail',{"params":{...params}})
//banner列表
export const  getBannerList = (params) => axios.get('merchant/wxapp/getBannerList',{"params":{...params}})
//设置关于我们
export const  setAboutUs = (params) => axios.post('merchant/wxapp/setAboutUs',params)
//获取关于我们
export const  getAboutUs = (params) => axios.get('merchant/wxapp/getAboutUs',params)


//功能区列表
export const  getButtonList = (params) => axios.get('merchant/wxapp/getButtonList',{"params":{...params}})
//功能去详情
export const  getButtonDetail = (params) => axios.get('merchant/wxapp/getButtonDetail',{"params":{...params}})
//设置功能区
export const  setButton = (params) => axios.post('merchant/wxapp/setButton',params)
//删除功能区
export const  delButton = (params) => axios.post('merchant/wxapp/delButton',params)

//订单列表
export const  getOrderList = (params) => axios.get('merchant/order/getOrderList',{"params":{...params}})
//药师推荐订单列表
export const  pharmacistRecommendMedicineList = (params) => axios.get('merchant/order/pharmacistRecommendMedicineList',{"params":{...params}})
//订单详细
export const  getOrderDetail = (params) => axios.get('merchant/order/getOrderDetail',{"params":{...params}})
//取消订单
export const cancelOrder = (params) => axios.post('merchant/order/cancelOrder',params)
//设置订单发货信息
export const setOrderShipInfo = (params) => axios.post('merchant/order/setOrderShipInfo',params)
//确认收货
export const confirmReceive = (params) => axios.post('merchant/order/confirmReceive',params)

//获取商品分类
export const  getGoodsClassify = (params) => axios.get('merchant/goods/getGoodsClassify',{"params":{...params}})

//获取商品规格
export const  getGoodsSkuList = (params) => axios.get('merchant/goods/getGoodsSkuList',{"params":{...params}})

//获取促销规则列表
export const  getDiscountSalesRule = (params) => axios.get('merchant/goods/getDiscountSalesRule',{"params":{...params}})
//设置促销规则
export const setDiscountSalesRule = (params) => axios.post('merchant/goods/setDiscountSalesRule',params)
//修改促销规则状态
export const changeDiscountSalesRuleStatus = (params) => axios.post('merchant/goods/changeDiscountSalesRuleStatus',params)
//删除促销规则
export const delDiscountSalesRule = (params) => axios.post('merchant/goods/delDiscountSalesRule',params)

//获取用户列表
export const  getUserList = (params) => axios.get('merchant/user/getUserList',{"params":{...params}})
//获取用户详情
export const  getUserDetail = (params) => axios.get('merchant/user/getUserDetail',{"params":{...params}})


//获取交易流水
export const  getEnterpriseMoneyChange = (params) => axios.get('merchant/data/getEnterpriseMoneyChange',{"params":{...params}})

//获取地图数据
// export const  getMapData = (params) => axios.get('https://apis.map.qq.com/ws/place/v1/search',{"params":{...params}})

//判断该UPC是否已经存在商品列表中
export const  selectGoodsExists = (params) => axios.get('merchant/goods/selectGoodsExists',{"params":{...params}})

//录入商品
export const importGoods = (params) => axios.post('merchant/goods/importGoods',params)


//财务导出
export const  enterpriseMoneyExport = (params) => axios.get('merchant/data/enterpriseMoneyExport',{"params":{...params}})
//订单导出
export const  orderExport = (params) => axios.get('merchant/order/orderExport',{"params":{...params}})

//获取未读的消息数量
export const  getUnreadNum = (params) => axios.get('merchant/data/getUnreadNum',{"params":{...params}})
//消息列表
export const  getMessageList = (params) => axios.get('merchant/data/getMessageList',{"params":{...params}})
//把消息设置为已读
export const setMessageAlreadyRead = (params) => axios.post('merchant/data/setMessageAlreadyRead',params)


//优惠券列表
export const  getCouponList = (params) => axios.get('merchant/coupon/getCouponList',{"params":{...params}})
//获取优惠券详情
export const getCouponDetail = (params) => axios.post('merchant/coupon/getCouponDetail',params)
//设置优惠券
export const setCoupon = (params) => axios.post('merchant/coupon/setCoupon',params)
//删除促销规则
export const delCoupon = (params) => axios.post('merchant/coupon/delCoupon',params)

//删除促销规则
export const orderRefund = (params) => axios.post('merchant/order/orderRefund',params)

//检查上传的Excel数据是否正确
export const checkExcel = (params) => axios.post('excel/checkExcel',params)
//确认导入数据
export const confirmImportStandardMedicine = (params) => axios.post('excel/confirmImportStandardMedicine',params)
//获取导入进度
export const  getImportStatus = (params) => axios.get('excel/getImportStatus',{"params":{...params}})
//获取门店二维码
export const  getMerchantQrCode = (params) => axios.get('merchant/getMerchantQrCode',{"params":{...params}})
//获取导出商品链接
export const  exportMedicine = (params) => axios.get('merchant/data/exportMedicine',{"params":{...params}})

//设置处方信息
export const setOrderPrescriptionInfo = (params) => axios.post('merchant/order/setOrderPrescriptionInfo',params)


//设置最高分销层级、最低提现金额
export const setCommonValue = (params) => axios.post('distribution/setCommonValue',params)
//获取最高分销层级、最低提现金额
export const  getCommonValue = (params) => axios.get('distribution/getCommonValue',{"params":{...params}})
//设置分销规则
export const setDistributionRule = (params) => axios.post('distribution/setDistributionRule',params)
//查看用户佣金
export const  getUserRebate = (params) => axios.get('distribution/getUserRebate',{"params":{...params}})
//获取下级分销商
export const  getDistributionNextUser  = (params) => axios.get('distribution/getDistributionNextUser',{"params":{...params}})
//获取分销规则列表
export const  getDistributionRule = (params) => axios.get('distribution/getDistributionRule',{"params":{...params}})
//获取分销商
export const  getDistributionUserList = (params) => axios.get('distribution/getDistributionUserList',{"params":{...params}})
//获取分销商审核列表
export const  getDistributionReviewList = (params) => axios.get('distribution/getDistributionReviewList',{"params":{...params}})
//审核分销商申请
export const reviewDistributionApplication = (params) => axios.post('distribution/reviewDistributionApplication',params)
//直接添加特约分销商
export const setDistributionSignedUser = (params) => axios.post('distribution/setDistributionSignedUser',params)
//获取提现列表接口
export const  getWithdrawsList = (params) => axios.get('distribution/getWithdrawsList',{"params":{...params}})
//审核接口
export const reviewWithdrawsList = (params) => axios.post('distribution/reviewWithdrawsList',params)
